package com.zgxt.demo.service.impl;


import com.zgxt.demo.entity.DialogueDetails;
import com.zgxt.demo.mapper.DialogueDetailsMapper;
import com.zgxt.demo.service.DialogueDetailsService;
import com.zgxt.demo.util.Conversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Service
public class DialogueDetailsServiceImpl implements DialogueDetailsService {

    //时间类
    Conversion conversion=new Conversion();

    @Autowired
    DialogueDetailsMapper dialogueDetailsMapper;







    @Override
    public List<DialogueDetails> selectSessionRecord(Integer userId, Integer currentPage, Integer rows) {
        return dialogueDetailsMapper.selectSessionRecord(userId,currentPage,rows);
    }

    @Override
    public void sessionRecord(String content, String userId, Integer identity) {
         dialogueDetailsMapper.sessionRecord(content,userId,identity,conversion.Time());
    }

    @Override
    public Integer deleteChat(Integer userId) {
        return dialogueDetailsMapper.deleteChat(userId);
    }

    @Override
    public Map<String, Object> QueryChatHistory(Integer pageIndex, Integer pageSize, String name) {
        Map<String, Object> map=new HashMap<>();
        map.put("data",dialogueDetailsMapper.QueryChatHistory(pageIndex,pageSize,name));
        map.put("count",dialogueDetailsMapper.ChatHistoryCount(name));
        return map;
    }

    @Override
    public Integer DisableChatHistory(String ids) {
        return dialogueDetailsMapper.deleteChatHistory(ids.split(","), conversion.Time());
    }


}
